import logging
import sys
from typing import List

# from databases import DatabaseURL
from loguru import logger
from starlette.config import Config
from starlette.datastructures import CommaSeparatedStrings, Secret

from app.core.logging import InterceptHandler
from app.core.logging import setup_logger

API_PREFIX = "/audit_api"

JWT_TOKEN_PREFIX = "Token"  # noqa: S105
VERSION = "1.0"

config = Config(".env")
a = 1
DEBUG: bool = config("DEBUG", cast=bool, default=False)

# 日志参数
log_file_path: str = config("log_file_path", cast=str)
log_file_name: str = config("log_file_name", cast=str)
logger_mode: str = config("logger_mode", cast=str)

mysql_client_path: str = config("mysql_client_path", cast=str)
data_backup_path: str = config("data_backup_path", cast=str)

SECRET_KEY: Secret = config("SECRET_KEY", cast=Secret)

PROJECT_NAME: str = config("PROJECT_NAME")
ALLOWED_HOSTS: List[str] = config(
    "ALLOWED_HOSTS",
    cast=CommaSeparatedStrings,
    default="",
)

# logging configuration
exec_log_file = f'{log_file_path}{log_file_name}'
setup_logger('exec_log', exec_log_file, level=logging.DEBUG, logger_mode=logger_mode)
exec_log = logging.getLogger('exec_log')
